<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <link rel="icon" type="image/x-icon" href="#" />
    <link href="__ADCSS__chcss/main.css" rel="stylesheet"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="__ADLIBS__jquery/jquery-1.11.1.min.js"></script>
    <title>账号登录</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }

        html,
        body {
            height: 100%;
        }

        @font-face {
            font-family: 'neo';
            src: url("__ADCSS__chcss/font/NEOTERICc.ttf");
        }
        input:focus{
            outline: none;
        }
        .form input{
            width: 300px;
            height: 30px;
            font-size: 18px;
            background: none;
            border: none;
            border-bottom: 1px solid #fff;
            color: #fff;
            margin-bottom: 20px;
        }
        .form input::placeholder{
            color: rgba(255,255,255,0.8);
            font-size: 18px;
            font-family: "neo";
        }
        .confirm{
            height: 0;
            overflow: hidden;
            transition: .25s;
        }
        .btn{
            width:140px;
            height: 40px;
            border: 1px solid #fff;
            background: none;
            font-size:20px;
            color: #fff;
            cursor: pointer;
            margin-top: 25px;
            font-family: "neo";
            transition: .25s;
        }
        .btn:hover{
            background: rgba(255,255,255,.25);
        }
        #login_wrap{
            width: 980px;
            min-height: 500px;
            border-radius: 10px;
            font-family: "neo";
            overflow: hidden;
            box-shadow: 0px 0px 120px rgba(0, 0, 0, 0.25);
            position: fixed;
            top: 50%;
            right: 50%;
            margin-top: -250px;
            margin-right: -490px;
        }
        #login{
            width: 50%;
            height: 100%;
            min-height: 500px;
            background: linear-gradient(45deg, #9a444e, #e06267);
            position: relative;
            float: right;
        }
        #login #status{
            width: 150px;
            height: 50px;
            margin: 20px auto;
            color: #fff;
            font-size: 30px;
            font-weight: 600;
            position: relative;
            overflow: hidden;
        }
        #login #status i{
            font-style: normal;
            position: absolute;
            transition: .5s
        }
        #login span{
            text-align: center;
            position: absolute;
            left: 50%;
            margin-left: -150px;
            top: 52%;
            margin-top: -140px;
        }
        #login span a{
            text-decoration: none;
            color: #fff;
            display: block;
            margin-top: 80px;
            font-size: 18px;
        }
        #bg{
            background: linear-gradient(45deg, #211136, #bf5853);
            height: 100%;
        }
        /*绘图*/
        #login_img{
            width: 50%;
            min-height: 500px;
            background: linear-gradient(45deg, #221334, #6c3049);
            float: left;
            position: relative;
        }
        #login_img span{
            position: absolute;
            display: block;
        }
        #login_img .circle{
            width: 200px;
            height: 200px;
            border-radius: 50%;
            background: linear-gradient(45deg, #df5555, #ef907a);
            top: 70px;
            left: 50%;
            margin-left: -100px;
            overflow: hidden;
        }
        #login_img .circle span{
            width: 150px;
            height: 40px;
            border-radius: 50px;
            position: absolute;
        }
        #login_img .circle span:nth-child(1){
            top: 30px;
            left: -38px;
            background: #c55c59;
        }
        #login_img .circle span:nth-child(2){
            bottom: 20px;
            right: -35px;
            background: #934555;
        }
        #login_img .star span{
            background: radial-gradient(#fff 10%,#fff 20%,rgba(72, 34, 64, 0));
            border-radius: 50%;
            box-shadow: 0 0 7px #fff;
        }
        #login_img .star span:nth-child(1){
            width: 15px;
            height: 15px;
            top: 50px;
            left: 30px;
        }
        #login_img .star span:nth-child(2){
            width: 10px;
            height: 10px;
            left: 360px;
            top: 80px;
        }
        #login_img .star span:nth-child(3){
            width: 5px;
            height: 5px;
            top: 400px;
            left: 80px;
        }
        #login_img .star span:nth-child(4){
            width: 8px;
            height: 8px;
            top: 240px;
            left: 60px;
        }
        #login_img .star span:nth-child(5){
            width: 4px;
            height: 4px;
            top: 20px;
            left: 200px;
        }
        #login_img .star span:nth-child(6){
            width: 4px;
            height: 4px;
            top: 460px;
            left: 410px;
        }
        #login_img .star span:nth-child(7){
            width: 6px;
            height: 6px;
            top: 250px;
            left: 350px;
        }
        #login_img .fly_star span{
            width: 90px;
            height: 3px;
            background: -webkit-linear-gradient(left, rgba(255, 255, 255, 0.67), rgba(255,255,255,0));
            background: -o-linear-gradient(left, rgba(255, 255, 255, 0.67), rgba(255,255,255,0));
            background: linear-gradient(to right, rgba(255, 255, 255, 0.67), rgba(255,255,255,0));
            transform: rotate(-45deg);
        }
        #login_img .fly_star span:nth-child(1){
            top:60px;
            left: 80px;
        }
        #login_img .fly_star span:nth-child(2){
            top: 210px;
            left: 332px;
            opacity: 0.6;
        }
        #login_img p{
            text-align: center;
            color: #af4b55;
            font-weight: 600;
            margin-top: 365px;
            font-size: 25px;
        }
        #login_img p i{
            font-style: normal;
            margin-right: 45px;
        }
        #login_img p i:nth-last-child(1){
            margin-right: 0;
        }
        /*提示*/
        #hint{
            width: 100%;
            line-height: 70px;
            background: linear-gradient(-90deg, #9b494d, #bf5853);
            text-align: center;
            font-size: 25px;
            color: #fff;
            box-shadow: 0 0 20px #733544;
            display: none;
            opacity: 0;
            transition: .5s;
            position: absolute;
            top: 0;
            z-index: 999;
        }
        /* 响应式 */
        @media screen and (max-width:1000px ) {
            #login_img{
                display: none;
            }
            #login_wrap{
                width: 490px;
                margin-right: -245px;
            }
            #login{
                width: 100%;

            }
        }
        @media screen and (max-width:560px ) {
            #login_wrap{
                width: 330px;
                margin-right: -165px;
            }
            #login span{
                margin-left: -125px;
            }
            .form input{
                width: 250px;
            }
            .btn{
                width: 113px;
            }
        }
        @media screen and (max-width:345px ) {
            #login_wrap {
                width: 290px;
                margin-right: -145px;
            }
        }
        #SMS{
            display: inline-block;
            width: 140px;
            height: 50px;
            background-color: #98A3A3;
            border-color: #98A3A3;
            color: #fff;
            font-size: 15px;
            line-height: 50px;
            box-shadow:1px 2px 3px #3c3c3c;
            cursor: pointer;
        }
        .login{
            width: 70px;
            height: 35px;
            color:#ffffff;
            font-size: 20px;
            background: none;
            border: none;
        }
    </style>
</head>
<body>

<div id="bg">
    <div id="hint"><!-- 提示框 -->
        <p>登录失败</p>
    </div>
    <div id="login_wrap">
        <div id="login"><!-- 登录注册切换动画 -->
            <div id="status">
                <button class="login aa" style="border-bottom:3px solid red">登 录</button>
                <button class="login bb" >注 册</button>
            </div>
            <span class="logindo" >
                    <form action="{:url('index/Index/getReg')}" onsubmit="return logindo()" method="post"  id="register">
                        <p class="form"><input name="name" type="text" class="doinfo user_name" placeholder="电话号码"></p>
                        <p class="form"><input name="password" type="password" class="doinfo user_pwd" placeholder="密码"></p>
                        <p class="form" ><input name="captcha" type="text"  data-captcha="false" class="user_cap" placeholder="验证码" ></p>
                        <p class="doerror" style="color:#ff0000"></p>
                        <p style="width: 130px;display: inline-block;">
                            <div>
                                <img src="{:captcha_src()}" id="verify_img" alt="captcha" title="点击刷新" onclick="refreshVerify()" />
                            </div>
                        </p>

                        <br>
                        <button type="submit"  class="btn" style="margin-right: 20px;" id="dl">登 录</button>
                    </form>

            </span>
            <span class="signdo" style="display: none">
                    <form action={:url('index/Index/getLogin')} method="post" onsubmit="return signdo()" id="signdo">
                        <p class="form"><input type="text" name="tel" id="dotel" class="sign" placeholder="用户名"></p>
                        <p class="form "><input type="text" name="email" id="doemail" class="sign" placeholder="邮箱"></p>
                        <p class="form"><input type="password" name="password" id="pwd" class="sign" placeholder="密码"></p>
                        <p class="form "><input type="password" name="repassword" id="repwd" class="sign" placeholder="确认密码"></p>
                        <p class="form" style="width: 120px; display: inline-block;margin-right:30px; "><input type="text" style="width: 120px" id="information" name="captcha" class="sign" placeholder="验证码"></p>
                        <button id="SMS" onClick="submitAction();return false">获取短信验证码</button>
                        <div class="doer" style="color:#ff0000"></div>
                        <button type="submit"  class="btn"  id="zhuce">注册</button>
                    </form>
            </span>
        </div>


        <div id="login_img"><!-- 图片绘制框 -->
            <a href="{:url('index/Index/index')}">

            <span class="circle">
                <div class="home" style="font-size: 40px;margin-left: 22px;margin-top: 70px;">返回首页</div>
                    <span></span>
                    <span></span>
                </span>
            </a>
            <span class="star">
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                </span>
            <span class="fly_star">
                    <span></span>
                    <span></span>
                </span>
            <p id="title">CLOUD</p>
        </div>
    </div>
</div>
</body>
<script>
    //登录提交验证
    function  logindo() {
        var naem = $('.user_name').val();
        var pwd = $('.user_pwd').val();
        var cap = $('.user_cap').val();
        var captcha = $('.user_cap').attr('data-captcha');

        if (naem == ''){
            alert('您的账号不能为空');
            return false;
        }
        if (pwd == ''){
            alert('您的密码不能为空');
            return false;
        }
        if (cap == ''){
            alert('您的验证码不能为空');
            return false;
        }
        if (captcha == 'false'){
            return false;
        }

        return true;
    }

    // 注册提交验证
    function  signdo() {
        var dotel = $('#dotel').val();
        var doemail = $('#doemail').val();
        var pwd = $('#pwd').val();
        var repwd = $('#repwd').val();
        var information = $('#information').val();

        if (dotel == ''){
            alert('您的账号不能为空');
            $('#zhuce').attr('disabled','disabled');
            return false;
        }
        if (doemail == ''){
            alert('您的邮箱不能为空');
            $('#zhuce').attr('disabled','disabled');
            return false;
        }
        if (pwd == ''){
            alert('您的密码不能为空');
            $('#zhuce').attr('disabled','disabled');
            return false;
        }
        if (repwd == ''){
            alert('您的确认密码不能为空');
            $('#zhuce').attr('disabled','disabled');
            return false;
        }
        if (information == ''){
            alert('您的短信验证码不能为空');
            $('#zhuce').attr('disabled','disabled');
            return false;
        }
        $('#zhuce').attr('disabled',false);
        return true;
    }

    //验证码实时验证
    $('.user_cap').keyup(function () {
        var captcha = $(this).val();
        console.log(captcha);
        if (captcha.length == 5){
            $.ajax({
                method : 'post',
                url    : 'captcha',
                data   : 'captcha='+captcha,
                dataType : 'json',
                success: function(data){
                    // console.log(data);
                    if(data.captcha  == 'false'){
                        $('.doerror').html(data.title);
                    }
                    if (data == true){
                        $('.user_cap').attr('data-captcha','true');
                        $('.doerror').html('');
                    }
                },
                error  : function (){
                    alert('您输入的信息有误');
                    return false;
                }
            });
        }
    });

    // 点击发送短信倒计时
    m = 60;
    function showbtn() {
        var  SMS = document.getElementById('SMS');
        var pClass= document.createAttribute('disabled');
        if (m <= 0) {
            SMS.disabled = false;
            SMS.innerHTML = '获取短信验证码';
            SMS.removeAttribute(pClass);
            return;
        }
        SMS.innerHTML = '('+m+')秒后可在发送';
        SMS.setAttributeNode(pClass);
        m--;
        setTimeout("showbtn()", 1000);
    }
    

    // 登录验证码
    function refreshVerify() {
        var ts = Date.parse(new Date())/1000;
        var img = document.getElementById('verify_img');
        img.src = "/captcha?id="+ts;
    }
    $(function (){
        // 登录注册转跳
        $('.login').click(function(){
            // console.log($(this).html());
            if ($(this).html() == '登 录'){
                // console.log(登录);
                $('.bb').attr('style','');
                $('.aa').attr('style','border-bottom:3px solid red');
                $('.logindo').attr('style','');
                $('.signdo').attr('style','display: none');
            }else if ($(this).html() == '注 册') {
                // console.log(注册);
                $('.aa').attr('style','');
                $('.bb').attr('style','border-bottom:3px solid red');
                $('.logindo').attr('style','display: none');
                $('.signdo').attr('style','');
            }
        });



        // 注册验证
        $('.sign').blur(function(){

            var user = $(this).val();
            var name = $(this).attr('name');
            if (name == 'repassword') {
                var pwd = $('#pwd').val();
                if (user == pwd){
                    $('#information').attr('disabled',false);
                    $('#SMS').attr('disabled',false);
                    $('.doer').html('');
                    return true;
                } else{
                    $('#information').attr('disabled','disabled');
                    $('#SMS').attr('disabled','disabled');
                    $('.doer').html('您两次密码不一致,请重新输入!!');
                    return false;
                }
            }
            // console.log(user,name);
            $.ajax({
                method : 'post',
                url    : 'register',
                data   : name+'='+user,
                dataType : 'json',
                success: function(data){
                    console.log(data);
                    if (data.tel  == 'false'){
                        $('.doer').html(data.title);
                        $('#SMS').attr('disabled','disabled');
                        $('#zhuce').attr('disabled','disabled');
                        $('#doemail').attr('disabled','disabled');
                        $('#pwd').attr('disabled','disabled');
                        $('#repwd').attr('disabled','disabled');
                        $('#information').attr('disabled','disabled');
                    }else if (data.tel  == 'true'){
                        $('.doer').html('');
                        $('#SMS').attr('disabled',false);
                        $('#doemail').attr('disabled',false);
                        $('#zhuce').attr('disabled',false);
                        $('#pwd').attr('disabled',false);
                        $('#repwd').attr('disabled',false);
                        $('#information').attr('disabled',false);
                        return true;
                    }

                    if (data.email  == 'false'){
                        $('.doer').html(data.title);
                        $('#zhuce').attr('disabled','disabled');
                        $('#pwd').attr('disabled','disabled');
                        $('#repwd').attr('disabled','disabled');
                        $('#information').attr('disabled','disabled');
                    }else if (data.email  == 'true'){
                        $('.doer').html('');
                        $('#zhuce').attr('disabled',false);
                        $('#pwd').attr('disabled',false);
                        $('#repwd').attr('disabled',false);
                        $('#information').attr('disabled',false);
                        return true;
                    }

                    if (data.password  == 'false') {
                        $('.doer').html(data.title);
                        $('#zhuce').attr('disabled','disabled');
                        $('#information').attr('disabled','disabled');
                    }else if (data.password  == 'true'){
                        $('.doer').html('');
                        $('#zhuce').attr('disabled',false);
                        $('#information').attr('disabled',false);
                        return true;
                    }

                    if(data.captcha  == 'false'){
                        $('.doer').html(data.title);
                        $('#zhuce').attr('disabled','disabled');
                    }else if(data.captcha  == 'true'){
                        $('.doer').html('');
                        $('#zhuce').attr('disabled',false);
                        return true;
                    }
                },
                error  : function (){
                    alert('您输入的信息有误');
                    return false;
                }
            });

        });




        // 登录验证
        $('.doinfo').blur(function(){
            var user = $(this).val();
            var name = $(this).attr('name');
            // console.log(user,name);
            $.ajax({
                method : 'post',
                url    : 'logindo',
                data   : name+'='+user,
                dataType : 'json',
                success: function(data){
                    if (data.tel  == 'false'){
                        $('.doerror').html(data.title);
                        $('#dl').attr('disabled','disabled');
                        $('.user_pwd').attr('disabled','disabled');
                        $('.user_cap').attr('disabled','disabled');
                    }else if(data.tel  == 'true'){
                        $('.doerror').html('');
                        $('#dl').attr('disabled',false);
                        $('.user_pwd').attr('disabled',false);
                        $('.user_cap').attr('disabled',false);
                    }

                    if (data.password  == 'false') {
                        $('.doerror').html(data.title);
                        $('#dl').attr('disabled','disabled');
                        $('.user_cap').attr('disabled','disabled');
                    }else if(data.password  == 'true'){
                        $('.doerror').html('');
                        $('#dl').attr('disabled',false);
                        $('.user_cap').attr('disabled',false);
                    }
                },
                error  : function (){
                    alert('您输入的信息有误');
                    return false;
                }
            });

        });

    });


    function login(status){
        status = 'false';
        return false;
    }


    // 验证码
    function submitAction(){
            var tel = $('#dotel').val();
            if (!(tel.length > 0) ){
                $('.doer').html('请输入用户名');
                return;
            }
            // console.log(tel);
            $.ajax({
                method : 'post',
                url    : 'SMS',
                data   : 'tel='+tel,
                dataType : 'json',
                success: function(data){
                    console.log(data);
                    showbtn();
                },
                error  : function (){
                    alert('短信验证码发送失败!');
                }
            });
    }



</script>

</html>

